﻿// GateWay.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include "pch.h"
#include <iostream>

// Copyright (c) 2016 Juan Delgado (JuDelCo)
// License: MIT License
// MIT License web page: https://opensource.org/licenses/MIT

#include "../ECS/SystemContainer.hpp"
#include "../ECS/Matcher.hpp"
#include "../ECS/Pool.hpp"
#include "../CommonLib/IDGenerater.hpp"
#include "../CommonLib/TimeHelper.h"
#include <string>

using namespace EntitasPP;

class DemoComponent : public IComponent {
public:
	void Reset(const std::string& name1, const std::string& name2) {
		std::cout << "Created new entity: " << name1 << "," << name2 << std::endl;
	}
};

class DemoSystem : public IInitializeSystem, public IExecuteSystem, public ISetPoolSystem {
public:
	void SetPool(Pool* pool) {
		mPool = pool;
	}
	void Initialize() {
		mPool->CreateEntity()->Add<DemoComponent>("foo", "bar");
		std::cout << "DemoSystem initialized" << std::endl;
	}
	void Execute() {
		mPool->CreateEntity()->Add<DemoComponent>("foo", "bar");

		auto entitiesCount = mPool->GetGroup(Matcher_AllOf(DemoComponent))->Count();
		std::cout << "There are " << entitiesCount << " entities with the component 'DemoComponent'" << std::endl;

		std::cout << "DemoSystem executed" << std::endl;
	}

private:
	Pool* mPool;
};

int main(const int argc, const char* argv[]) {
	auto systems = std::make_shared<SystemContainer>();
	auto pool = std::make_shared<Pool>();

	systems->Add(pool->CreateSystem<DemoSystem>());
	systems->Initialize();

	for (unsigned int i = 0; i < 2; ++i) {
		systems->Execute();
	}
	
	return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门提示: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件
